import { createContext } from "react";

interface ThemeProps {
  fontSize: 12 | 13 | number;
}

/**
 * be careof the settings, use as less as you can
 */

const DefaultConfig = {
  fontSize: 12,
};

const ThemeContext = createContext<ThemeProps>(DefaultConfig);

const ThemeProvider = ThemeContext.Provider;

let theme: Object | undefined;

function createTheme({ fontSize }: ThemeProps) {
  if (!theme)
    theme = Object.assign({}, DefaultConfig, {
      fontSize,
    });
  return theme as ThemeProps;
}

export { ThemeProvider, createTheme, ThemeContext };
